﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplicationEditPaymentPlan.ascx.cs" Inherits="CentralOffice.WebClient.Tasks.ApplicationEditPaymentPlan" %>


<style type="text/css">
    /*AutoComplete flyout */
.autocomplete_completionListElement 
{  
	margin : 0px!important;
	background-color : inherit;
	color : windowtext;
	border : buttonshadow;
	border-width : 1px;
	border-style : solid;
	cursor : 'default';
	overflow : auto;
	height : 200px;
    text-align : left; 
    list-style-type : none;
    padding:0;
    margin:0;
}

/* AutoComplete highlighted item */

.autocomplete_highlightedListItem
{
	background-color: #ffff99;
	color: black;
	padding: 1px;
    text-align:left;
}

/* AutoComplete item */

.autocomplete_listItem 
{
	background-color : window;
	color : windowtext;
	padding : 1px;
	text-align:left;
}

/*
.itemWidth
{
	width:100px;
	text-align:left;
	padding:0;
	border-left:solid 1px #c0c0c0;
	border-right:solid 1px #c0c0c0;
	border-bottom:solid 1px #c0c0c0;
	display:inline-block;
}
*/
    </style>
    

    
<table class="TableBlock" width="90%" align="center">
    <tr><td nowrap class="TableData" style="width: 113px">申请类别：</td><td nowrap class="TableData"><asp:Literal ID="lblCategory" runat="server"></asp:Literal></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">采用的审批流程：</td><td nowrap class="TableData"><asp:Literal ID="lblProcess" runat="server"></asp:Literal>&nbsp;&nbsp;&nbsp;&nbsp;执行人：&nbsp;&nbsp;<asp:Literal ID="txtExecutor" runat="server"></asp:Literal></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">申请编号：</td><td nowrap class="TableData"><asp:TextBox ID="txtApplicationCode" runat="server" CssClass="BigInput" style="width:82%"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="格式不正确" ValidationExpression="^\d{8}-\d{3}$" ControlToValidate="txtApplicationCode">(格式错误)</asp:RegularExpressionValidator></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">申请名称：</td><td nowrap class="TableData"><asp:TextBox ID="txtName" runat="server" CssClass="BigInput" style="width:82%"></asp:TextBox><span class="warning">（请先填写名称）</span><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="任务名称必须填写" ControlToValidate="txtName">*</asp:RequiredFieldValidator></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">申请人：</td><td nowrap class="TableData"><asp:Literal ID="lblApplicant" runat="server"></asp:Literal></td></tr>
    <tr><td nowrap class="TableData" style="width: 113px">审批内容：</td><td nowrap class="TableData"><asp:TextBox ID="txtContentText" runat="server" TextMode="MultiLine" Columns="120" Rows="5"></asp:TextBox></td></tr>
    <tr><td class="TableData">附件：</td><td class="TableData"><asp:FileUpload ID="fileAttachments" runat="server" Width="78%" /></td></tr>
    <%--<tr><td nowrap class="TableControl" colspan="2" align="center"><asp:Button ID="btnSave" runat="server" Text="确定" CssClass="BigButton"  OnClick="btnSave_Click" /></td></tr>--%>
</table>
<asp:HiddenField ID="txtProcessId" runat="server" />
<div style="margin-top:20px; margin-left:8px;"><h3>请输入供应商</h3></div>

<div style="text-align:center">
<table class="TableBlock " style="margin-left:60px;" >
    <tr><td nowrap class="TableData" style="width:60px;">供应商：</td><td nowrap class="TableData fontBold" style="text-align:left;" ><asp:TextBox ID="txtCustomer" runat="server" CssClass="BigInput" Width="360" ></asp:TextBox></td></tr>
   <tr><td nowrap class="TableData" style="width:60px;">金额：</td><td nowrap class="TableData fontBold" style="text-align:left;" ><asp:TextBox ID="txtTotalDue" runat="server" CssClass="BigInput" Width="360" onblur="return isValidate(this);" onkeydown="onKeyDownDue(event);" ></asp:TextBox></tr>
   <tr><td nowrap class="TableData" style="width:60px;">付款内容：</td><td nowrap class="TableData fontBold" style="text-align:left;" ><asp:TextBox ID="txtSubject" runat="server" CssClass="BigInput" Width="360" onkeydown="onKeyDownSubject(event);"></asp:TextBox></tr>
   <tr><td nowrap class="TableData" style="width:60px;">备注：</td><td nowrap class="TableData fontBold" style="text-align:left;" ><asp:TextBox ID="txtRemark" runat="server" CssClass="BigInput" Width="360"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnOK" runat="server" onclick="btnSavePlan_Click" Text="确定" onkeydown= "onKeyDown(event)" /></tr>
</table>
</div>

<div style="margin-top:20px; margin-left:8px;"><h3>付款列表：</h3></div>
<div style="text-align:center">

<%--<asp:UpdatePanel UpdateMode="Conditional" ID="upItems" runat="server" ChildrenAsTriggers="false">
<ContentTemplate>
--%>
<huag:OAGridView  id="gvPaymentItem" runat="server" DataKeyNames="Id" 
        EnableExport="True" ConfirmDelete="True" 
        skinid="GridView" Width="90%"  EnableViewState="True"  
        ButtonColumnIndex="2" DeleteButtonIndex="0" EnableCheck="False" 
        EnableTruncate="True" onrowdeleting="gvPaymentItem_RowDeleting" 
        onrowediting="gvPaymentItem_RowEditing" 
        onrowcancelingedit="gvPaymentItem_RowCancelingEdit" 
        onrowupdated="gvPaymentItem_RowUpdated" 
        onrowupdating="gvPaymentItem_RowUpdating" ShowFooter="true" >
   <Columns>
       <asp:TemplateField HeaderText="序号"><ItemTemplate>  <%# Container.DataItemIndex+1 %></ItemTemplate></asp:TemplateField>
       <asp:BoundField DataField="Customer" HeaderText="供应商"   ReadOnly="True"/>
       <asp:BoundField DataField="Subject" HeaderText="付款内容"   ReadOnly="True"/>
       
       <asp:BoundField DataField="TotalDue" HeaderText="应付款" />
       <asp:BoundField DataField="Remark" HeaderText="备注" ReadOnly="True" />
       <asp:CommandField ShowEditButton="true" ShowCancelButton="true" ShowDeleteButton="true" />
   </Columns>
</huag:OAGridView>

<%--
</ContentTemplate>
 <Triggers><asp:AsyncPostBackTrigger ControlID="btnOK" /></Triggers>
</asp:UpdatePanel>--%>

</div>


<div style="margin-top:20px; margin-left:8px;"><h3>审批步骤：</h3></div>
<div style="text-align:center">


<huag:OAGridView  id="gvStep" runat="server" DataKeyNames="Id" AllowSorting="True"  EnableExport="false" ConfirmDelete="true" skinid="GridView" Width="90%"  EnableViewState="True" >
   <Columns>
       <asp:BoundField DataField="StepOrder" HeaderText="步骤序号" SortExpression="StepOrder" />
       <asp:BoundField DataField="Name" HeaderText="步骤名称" SortExpression="Name"/>
       <asp:BoundField DataField="ApprovalProcess" HeaderText="所属审批流程" SortExpression="ApprovalProcess" />
       <asp:BoundField DataField="ApprovalByEmp" HeaderText="审批者" SortExpression="ApprovalByEmp" />
       <asp:BoundField DataField="ApprovalBy" HeaderText="审批角色" SortExpression="ApprovalBy" />
       <asp:BoundField DataField="ApprovalContent" HeaderText="要审批的内容" SortExpression="ApprovalContent" />
   </Columns>
</huag:OAGridView>

</div>

<div style="text-align:center; margin-top:10px;"><asp:Button ID="btnSave" runat="server" Text="确定" CssClass="BigButton"  OnClick="btnSave_Click" /></div>

<asp:Literal ID="lblJavaScript" EnableViewState="false" runat="server"></asp:Literal>

    <ajaxToolkit:AutoCompleteExtender
                runat="server" 
                BehaviorID="customerBehavior"
                ID="aceCustomer"
                TargetControlID="txtCustomer"
                ServicePath="~/CommonServices/GetCustomers.asmx" 
                ServiceMethod="GetAllCustomers"
                MinimumPrefixLength="1" 
                CompletionInterval="300"
                EnableCaching="false"
                CompletionSetCount="30"
                CompletionListCssClass="autocomplete_completionListElement" 
                CompletionListItemCssClass="autocomplete_listItem" 
                CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                DelimiterCharacters=";, :"
                
                FirstRowSelected="true"
                OnClientItemSelected="setFocus"
                >
    </ajaxToolkit:AutoCompleteExtender>


<script type="text/javascript">
    //<![CDATA[
    function setFocus(source, eventArgs) {
        //var provinceId = eventArgs.get_value();
        //$find('cityBehavior').set_contextKey(provinceId);

        //$get("txtProvinceID").value = provinceId;
        $get("<%= txtTotalDue.ClientID %>").focus();
    }

    // onkeydown= "onKeyDown(event)";
    //$addHandler("<%= txtTotalDue.ClientID %>", "keydown", onKeyDown);

    function onKeyDownDue(e) {
		//e = event || window.event;
        if (e && e.keyCode == Sys.UI.Key.enter) {
            //alert("<%= txtSubject.ClientID %>");
			
			//alert(e);
			//alert(e.preventDefault);
			if(e.preventDefault) 
			{
				e.preventDefault();
			}
			else
			{
				e.returnValue = false;
			}
            $get("<%= txtSubject.ClientID %>").focus();
			//document.getElementById("ApplicationEditPaymentPlan1_txtSubject").focus();
        }
        
    
    }
    function onKeyDownSubject(e) {
        if (e && e.keyCode == Sys.UI.Key.enter) {
			//e.preventDefault();
			if(e.preventDefault) 
			{
				e.preventDefault();
			}
			else
			{
				e.returnValue = false;
			}
            $get("<%= txtRemark.ClientID %>").focus();
        }
    }
    
    function onKeyDown(e) {
        if (e && e.keyCode == Sys.UI.Key.enter) {
            
            //e.preventDefault();
            //$get("<%= txtTotalDue.ClientID %>").click();
//            alert($get("<%= txtTotalDue.ClientID %>").tagName);
        }
    }
    var paymentList = $get("<%= gvPaymentItem.ClientID %>");
    var rowLength = paymentList ? paymentList.rows.length : 0;
    if (rowLength > 0) {
        paymentList.rows.item(rowLength - 1).cells.item(1).innerHTML = "<span class='warning'>合计：</span>";
        var total = 0;
        for(var i = 1; i < rowLength - 1; i++) {

            var itemValue = paymentList.rows.item(i).cells.item(3).innerHTML;
            
            if (itemValue && itemValue.length > 0) {
                total += parseFloat(itemValue);
            }
        }

        paymentList.rows.item(rowLength - 1).cells.item(3).innerHTML = "<span class='warning'>" + total + "</span>";
    }

    function isValidate(txt) {
        //alert(txt.value);
        if (!isNum(txt.value)) {
            alert("金额的格式不正确！");
            return false;
        }
        return true;
    }
    //]]>
</script>    